import request from '@/utils/request';
import {AxiosPromise} from 'axios';

const API_BASE = '/ai/chat/deep_seek';

const API_SUFFIXES = {
    /** 对话 */
    CHAT: '/chat',
    /** 中断 */
    // INTERRUPT: '{conversationId}/interrupt',
    /** 重试 */
    RETRY: '/{conversationId}/retry',
    /** 删除消息 */
    DELETE_MESSAGE : '/{conversationId}'
};


export class AiChatAPI {

    /**
     * 会话
     */
    static CHAT = {
        endpoint: `${import.meta.env.VITE_APP_API_URL}${API_BASE}${API_SUFFIXES.CHAT}`,
        permission: 'ai:chat:stream'
    }

    // /**
    //  * 中断响应
    //  */
    // static INTERRUPT = {
    //     endpoint: (conversationId: string) => `${API_BASE}${API_SUFFIXES.INTERRUPT.replace("conversationId", conversationId)}`,
    //     permission: 'ai:chat:interrupt',
    //     request: (conversationId: string): AxiosPromise<void> => {
    //         return request<void>({
    //             url: AiChatAPI.INTERRUPT.endpoint(conversationId),
    //             method: 'post'
    //         });
    //     }
    // }

    /**
     * 重试
     */
    static RETRY = {
        endpoint: (conversationId: string) => `${import.meta.env.VITE_APP_API_URL}${API_BASE}${API_SUFFIXES.RETRY.replace("{conversationId}", conversationId)}`,
        permission: 'ai:chat:retry',
        request: (conversationId: string): AxiosPromise<void> => {
            return request<void>({
                url: AiChatAPI.RETRY.endpoint(conversationId),
                method: 'post'
            });
        }
    }

    /**
     * 删除
     */
    static DELETE_MESSAGE = {
        endpoint: (conversationId: string) => `${API_BASE}${API_SUFFIXES.DELETE_MESSAGE.replace("{conversationId}", conversationId)}`,
        permission: 'ai:chat:delete',
        request: (conversationId: string): AxiosPromise<void> => {
            return request<void>({
                url: AiChatAPI.DELETE_MESSAGE.endpoint(conversationId),
                method: 'delete'
            });
        }
    }
}

